package java_generics;

// The type parameter T should not be bounded by the final type Integer.
// Final types cannot be further extended
public class NaturalNumber <T extends Integer> {
	
	private T n;

    public NaturalNumber(T n)  { this.n = n; }

    public String isEven() {
        if (n.intValue() % 2 == 0) {
        	return "even";
        }else{
        	return "odd";
        }
    }
    
    public T get(){ return n; }
    
	public static void main(String[] args) {
		NaturalNumber <Integer> x = new NaturalNumber<> (20);
		System.out.printf("%d is %s",x.get(),x.isEven());
		
		System.out.println("\n");
		
		NaturalNumber <Integer> y = new NaturalNumber<> (15);
		System.out.printf("%d is %s",y.get(),y.isEven());
		
		// NaturalNumber<String> z; // Not Integer

	}

}

// 20 is even

// 15 is odd